<template>
  <div>
    <div class="configHead">端口信息:<span style="color: #FF5722;font-size:0.25rem;">{{channelTip}}</span>
    </div>
    <div class="configBox" v-if="channelInfo.channel_type &&
            channelInfo.channel_type.indexOf('rs')>=0">
      <div><span>端口：</span>{{channelToUpper(channelInfo.channel_type)}}</div>
      <div><span>波特率：</span>{{channelInfo.channel_config.baud_rate}}bps</div>
      <div><span>数据位：</span>{{channelInfo.channel_config.data_bits}}</div>
      <div><span>停止位：</span>{{channelInfo.channel_config.stop_bits}}</div>
      <div><span>校验位：</span>{{channelInfo.channel_config.parity}}</div>
    </div>
    <div class="configBox" v-if="channelInfo.channel_type &&
		    channelInfo.channel_type.indexOf('com')==0">
      <div><span>端口：</span>{{channelToUpper(channelInfo.channel_type)}}</div>
      <div ><span>运行模式：</span>{{channelInfo.channel_mode==0?'边缘采集':'数据透传'}}</div>
      <div><span>波特率：</span>{{channelInfo.channel_config.baud_rate}}bps</div>
      <div><span>数据位：</span>{{channelInfo.channel_config.data_bits}}</div>
      <div><span>停止位：</span>{{channelInfo.channel_config.stop_bits}}</div>
      <div><span>校验位：</span>{{channelInfo.channel_config.parity}}</div>
      <div >
        <span>断帧时间：</span>{{channelInfo.channel_config.timeout==0?'自动':channelInfo.channel_config.timeout+'ms'}}</div>
    </div>
    <div class="configBox" v-if="channelInfo.channel_type &&
            channelInfo.channel_type.indexOf('thernet')>=0">
      <div><span>端口：</span>{{channelToUpper(channelInfo.channel_type)}}</div>
      <!-- <div v-show="version==3"><span>运行模式：</span>{{channelInfo.channel_mode==0?'边缘采集':'数据透传'}}</div> -->
      <div><span>自动获取IP：</span>{{channelInfo.channel_config.dhcp==1?'是':'否'}}</div>
      <div><span>默认网关：</span>{{channelInfo.channel_config.gateway}}</div>
      <div><span>子网掩码：</span>{{channelInfo.channel_config.subnet_mask}}</div>
      <div><span>网关IP：</span>{{channelInfo.channel_config.local_ip}}</div>
      <div><span>DNS：</span>{{channelInfo.channel_config.dns}}</div>
      <div><span>DNS2：</span>{{channelInfo.channel_config.dns2}}</div>
      <div><span>NTP：</span>{{channelInfo.channel_config.ntp}}</div>
      <!-- <div><span>云盒Port：</span>{{channelInfo.channel_config.local_port}}</div> -->
    </div>
    <div class="configBox" v-if="channelInfo.channel_type &&
            channelInfo.channel_type.indexOf('ora')>=0">
      <div><span>端口：</span>{{channelToUpper(channelInfo.channel_type)}}</div>
      <div ><span>运行模式：</span>{{channelInfo.channel_mode==0?'边缘采集':'数据透传'}}</div>
      <div><span>通讯信道：</span>{{channelInfo.channel_config.channel}}</div>
      <div><span>模块地址：</span>{{channelInfo.channel_config.address}}</div>
      <div><span>空中速率：</span>{{channelInfo.channel_config.air_rate}}bps</div>
      <div >
        <span>断帧时间：</span>{{channelInfo.channel_config.timeout==0?'自动':channelInfo.channel_config.timeout+'ms'}}</div>
      <div><span>数据加密：</span>{{channelInfo.channel_config.data_encrypt==1?'开':'关'}}</div>
      <div><span>网络ID：</span>{{channelInfo.channel_config.net_id}}</div>
    </div>
    <div class="configBox" v-if="channelInfo.channel_type &&
            channelInfo.channel_type.indexOf('igbee')>=0">
      <div><span>端口：</span>{{channelToUpper(channelInfo.channel_type)}}</div>
      <div ><span>运行模式：</span>{{channelInfo.channel_mode==0?'边缘采集':'数据透传'}}</div>
      <div><span>通讯信道：</span>{{channelInfo.channel_config.channel}}</div>
      <div><span>PAN ID：</span>{{channelInfo.channel_config.pan_id}}</div>
      <div ><span>断帧时间：</span>{{channelInfo.channel_config.timeout==0?'自动':channelInfo.channel_config.timeout+'ms'}}</div>
    </div>
    <div class="configBox" v-if="channelInfo.channel_type &&
            channelInfo.channel_type.indexOf('ocal')>=0">
      <div><span>端口：</span>{{channelToUpper(channelInfo.channel_type)}}</div>
      <!-- <div ><span>运行模式：</span>{{channelInfo.channel_mode==0?'边缘采集':'数据透传'}}</div> -->
      <div v-if="isRead"><span>DI数量：</span>{{channelInfo.channel_config.di_count}}</div>
      <div v-if="isRead"><span>DO数量：</span>{{channelInfo.channel_config.do_count}}</div>
      <div v-if="isRead"><span>AI数量：</span>{{channelInfo.channel_config.ai_count}}</div>
      <div v-if="isRead"><span>AO数量：</span>{{channelInfo.channel_config.ao_count}}</div>
      <div v-if="isRead"><span>温度计数量：</span>{{channelInfo.channel_config.temp_count}}</div>
      <div v-if="isRead"><span>PI数量：</span>{{channelInfo.channel_config.pi_count}}</div>
    </div>
  </div>
</template>
<script>
  export default {
    name: 'ChannelInfo',
    data() {
      return {

      }
    },
    props: ['channelInfo', 'channelTip', 'version','isRead'],
    // props: {
    //     channelInfo: {
    //         type: Object,
    //         default: {
    //             channel_type: 'ethernet',
    //             channel_config: {

    //             }
    //         }
    //     }



    // },

  }
</script>
<style lang="">
  .configHead {
    min-height: 0.5rem;
    max-height: 1rem;
    line-height: 0.5rem;
    font-size: 0.3rem;
    text-align: left;
    /* margin-bottom:0.2rem; */
    border-bottom: 1px solid #ccc;
  }

  .configBox {
    width: 100%;
    padding: 0;
    padding-top: 0.1rem;
    text-align: left;
    /* padding: 0.1rem; */
    font-size: 0.3rem;
    line-height: 0.5rem;
    /* border:1px solid red; */
  }

  .configBox span {
    display: inline-block;
    min-width: 0.6rem;
    /* width:auto; */
    text-align: right;
    /*text-align:right;*/
  }
</style>
